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

Can't deploy django server #5

Closed
mickytwenty56 opened this issue Aug 5, 2020 · 3 comments
Closed

Can't deploy django server #5

mickytwenty56 opened this issue Aug 5, 2020 · 3 comments

Comments

@mickytwenty56
Copy link

mickytwenty56 commented Aug 5, 2020

I'd read your post with relation to django,react,jwt. It's great and very useful for me.
I tried to deploy on localhost, but failed, even though after downloading this git project.
In condition of development, in other words, when I am using localhost:8000 as backend, localhost:3000 as frontend,
it does work well. But building is failed.

I followed your blog and make my project just like to your project's structure.
After entered localhost:8000, there was empty in my screen and some errors below in console.

1)Refused to execute script from 'http://localhost:8000/static/bundle.c3b68b6c3ff630372eb4.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
2)Refused to execute script from 'http://localhost:8000/static/vendor.6af475534d9e3f239f45.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

-I tried to execute scripts in package.json using yarn build or npm build, so the structure of mine is just like to your blog.
-I can't see login page in localhost:8000 after python manage.py runserver

I can't find out any clue to this. If I missed something, Could you let me know this reason?
Thanks a lot.

@c-v-ya
Copy link
Owner

c-v-ya commented Aug 6, 2020

Hi, thanks for feedback!

I've just cloned this repo, then:

  • created a .env file with variables
  • cd frontend && yarn && yarn build
  • cd ../ && export $(cat .env | xargs)
  • python -m venv venv && source venv/bin/activate
  • pip install -r requirements.txt
  • python manage.py migrate && python manage.py runserver

And after navigating to localhost:8000 got my login form.

At first I thought I forgot to set type on scripts in templatetags but that's not the case. So there is something else going on. And I wish I knew the reason, but unfortunately I don't. There is a SO question just like that but I have no idea if that works.

So, I know it's a terrible advice, but maybe clone the repo again and repeat those steps? 😅

@mickytwenty56
Copy link
Author

mickytwenty56 commented Aug 7, 2020

Thank you in advance. It's my mistake and I fixed it.

The reason is that I have made some change in this project.
I did something like below things.
1)pip django-cors-headers==3.4.0
2)django-cors-headers==3.4.0

I think it is related with cross-origin, but it made errors.
Finally, I would like to ask you to solve my problem. It will be very easy for you, but I don't.

The problem is that I want to make user login form which is customized.
Of course, I want to use your login section in the project.

In my customized login form, there are combobox for inputing userid, not textfield.
This is only different thing from your login form.
User can input userid by selecting the userid inside userid combobox, not typing userid in textbox.

My problem is to make some api for extracting userid from user table and add those into the combobox of userid in frontend.
Could you make some api for backend,some changes for frontend and upload it your repository?
I like your coding style. I can guess you are good backend developer including laravel etc. 🍎
So I would like to follow you and interact in the future.
Thanks a lot.

@c-v-ya
Copy link
Owner

c-v-ya commented Aug 7, 2020

I'm happy you've resolved that issue! In my case CORS headers are only needed for local development since in production backend serves react app itself and doesn't need them. But if you have different servers, then you'd need that settings too. That might not be clear from the article.

Now, about your request. I'm very flattered by your words, thank you! Yet I don't know a thing about laravel, my focus is on python and related stuff. But I digress. In my opinion, no one will do anything on the internet for free unless they're bored. So, I could do what you need, but I don't have a lot of free time to do that. Even if that was a payable thing I'd think about it before agreeing. Maybe you can find some junior developer who would like to up their skills and they'd do that for you. Or better yet, do it yourself. Because what you need is kind of a trivial thing. You'll learn a lot by doing it.

So I'm closing this as the problem itself was solved.

@c-v-ya c-v-ya closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants