Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Development] Issue with developing locally #229

Closed
opott opened this issue Jun 4, 2024 · 7 comments
Closed

[Development] Issue with developing locally #229

opott opened this issue Jun 4, 2024 · 7 comments
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@opott
Copy link
Contributor

opott commented Jun 4, 2024

When I have tried to add new audio files to the site, I noticed that I get an error when I attempt to test an announcement with the audio snippet that I added.

From what I can gather, it's because the site is programmed to get the files from a CDN, which obviously doesn't contain the files that I'm adding.

Could anyone advise me on a way around this for local development and testing?

@davwheat
Copy link
Owner

davwheat commented Jun 9, 2024

I'll try to look into a fix for this... Essentially, builds were taking far too long on Cloudflare and I was also worried about hitting storage and file count limitations on Cloudflare Pages, hence moving the audio to separate storage.

You might be able to use something like Python's simple web server by running it in the audio/ folder and updating the audio URL prefix in the source code for now.

cd audio
python3 -m http.server 9000

Then update the following lines:

generateAudioFileUrl(fileId: string, customPrefix?: string): string {
return `https://cdn.railannouncements.co.uk/${customPrefix || this.FILE_PREFIX}/${this.processAudioFileId(fileId).replace(/\./g, '/')}.mp3`
}

to:

  generateAudioFileUrl(fileId: string, customPrefix?: string): string {
    return `http:https://localhost:9000/${customPrefix || this.FILE_PREFIX}/${this.processAudioFileId(fileId).replace(/\./g, '/')}.mp3`
  }

@davwheat davwheat added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jun 9, 2024
@davwheat davwheat assigned davwheat and unassigned davwheat Jun 9, 2024
@opott
Copy link
Contributor Author

opott commented Jun 16, 2024

@davwheat
Just tried your suggested fix, but no luck.

I get this error on the site:
image

And this error in the Python terminal:

@opott ➜ /workspaces/rail-announcements/audio (main) $ python3 -m http.server 9000
Serving HTTP on 0.0.0.0 port 9000 (http:https://0.0.0.0:9000/) ...
127.0.0.1 - - [16/Jun/2024 12:32:11] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [16/Jun/2024 12:32:11] "OPTIONS /SN/377/bing%20bong.mp3 HTTP/1.1" 501 -
127.0.0.1 - - [16/Jun/2024 12:32:11] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [16/Jun/2024 12:32:11] "OPTIONS /SN/377/stations/ABW.mp3 HTTP/1.1" 501 -
127.0.0.1 - - [16/Jun/2024 12:32:11] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [16/Jun/2024 12:32:11] "OPTIONS /SN/377/please%20mind%20the%20gap%20between%20the%20train%20and%20the%20platform.mp3 HTTP/1.1" 501 -
127.0.0.1 - - [16/Jun/2024 12:32:11] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [16/Jun/2024 12:32:11] "OPTIONS /SN/377/we%20are%20now%20approaching.mp3 HTTP/1.1" 501 -

@davwheat davwheat self-assigned this Jul 6, 2024
@davwheat
Copy link
Owner

davwheat commented Jul 6, 2024

Sorry this took so long... This should be better now from changes in 9313af4 and 58ee9b5.

I've added some new info to the README for local development. In a nutshell, run these three in different terminals one after the other:

yarn develop
yarn develop:workers
yarn serve-audio

You can access the site on http:https://local.davw.network:8787 (local.davw.network points to 127.0.0.1 and is needed for CORS stuff)

Let me know if you still have issues.

@davwheat davwheat closed this as completed Jul 6, 2024
@opott
Copy link
Contributor Author

opott commented Jul 7, 2024

Hi. Not sure if I am doing something wrong here, but when I follow the steps provided and access the site, I get an error when I open a page for an announcement system.
image

However, the Celia & Phil pages appear to work properly, as well as the live trains. I am only having issues opening the pages for onboard systems and the ScotRail station system.

@davwheat
Copy link
Owner

davwheat commented Jul 7, 2024

Oh, I just broke something with my latest change. Not your fault...

@opott
Copy link
Contributor Author

opott commented Jul 7, 2024

Oh, that's alright. I thought I was doing something wrong! 😂

@davwheat
Copy link
Owner

davwheat commented Jul 7, 2024

That should also be fixed with the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants